package com.xy.bean;

import com.xy.config.MainConfig;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import sun.security.tools.keytool.Main;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/4/6 15:29
 * @description
 */


public class MainTest {

    public static void main(String[] args) {
        // IOC容器  老方法 xml配置
        /*ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
        Person person = context.getBean(Person.class);
        System.out.println("person = " + person);*/

        // IOC容器
        ApplicationContext context = new AnnotationConfigApplicationContext(MainConfig.class);
        Person person = context.getBean(Person.class);
        System.out.println("person = " + person);
        String[] names = context.getBeanNamesForType(Person.class); //方法名
        for (String name : names) {
            System.out.println("name = " + name);
        }
    }
}
